﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CINES.ITECH.BUSINESS.ENTITIES;
using Microsoft.ApplicationBlocks.Data;
using System.Data;
using System.Collections.Generic;

namespace CINES.ITECH.DATA.ACCESS
{
    public class DA_CINE
    {
        public DataSet D_ListarCines()
        {
            DataSet ds = new DataSet();
            String sSQL = "";

            sSQL = "set language spanish EXEC SP_CINE_S01 ";

            try
            {
                ds = SqlHelper.ExecuteDataset(CONFIGURACION.gsCNitech, CommandType.Text, sSQL);
                return ds;
            }
            catch
            {
                return ds;
            }
        }

        private BE_CINE fr_Populate(IDataRecord dr)
        {
            BE_CINE objEntidad = new BE_CINE();

            if (dr["cod_cine"] != null)
                if (!Convert.IsDBNull(dr["cod_cine"]))
                    objEntidad.Codcine = Convert.ToString(dr["cod_cine"]);

            if (dr["nombre"] != null)
                if (!Convert.IsDBNull(dr["nombre"]))
                    objEntidad.Nombre = Convert.ToString(dr["nombre"]);

            //if (dr["direccion"] != null)
            //    if (!Convert.IsDBNull(dr["direccion"]))
            //        objEntidad.Direccion = Convert.ToString(dr["direccion"]);

            //if (dr["telefono"] != null)
            //    if (!Convert.IsDBNull(dr["telefono"]))
            //        objEntidad.Telefono = Convert.ToString(dr["telefono"]);

            //if (dr["calificacion"] != null)
            //    if (!Convert.IsDBNull(dr["calificacion"]))
            //        objEntidad.Calificacion = Convert.ToInt32(dr["calificacion"]);

            return objEntidad;
        }


        public List<BE_CINE> D_ListarCine()
        {
            List<BE_CINE> lstCinesBE = new List<BE_CINE>();
            IDataReader reader;
            String sSQL = "";
            sSQL = "set language spanish EXEC SP_CINES";
            try
            {
                reader = SqlHelper.ExecuteReader(CONFIGURACION.gsCNitech, CommandType.Text, sSQL);
                while (reader.Read())
                {
                    lstCinesBE.Add(fr_Populate(reader));
                }
                return lstCinesBE;
            }
            catch
            {
                return lstCinesBE;
            }
        }

    }
}
